#include "NetControlPointCmd.h"

NetControlPointCmd::NetControlPointCmd(QObject *parent) :
    BaseCmd(parent)
{
    this->m_protocolType = ProtocolType::NetPointProtocol;
    this->m_functionCode = FunctionCode;
    m_address = 0;
    m_value=0;
}


Package NetControlPointCmd::toPackage()
{
    Package package;
    QByteArray body;

    body.append(DataTypeConver::intToByteArray(m_address,2));
    body.append(DataTypeConver::intToByteArray(m_value,2));

    package.setFunction(FunctionCode);
    package.setBody(body);
    return package;
}

void NetControlPointCmd::unPackage(Package package)
{
    m_address = package.body().mid(0,2).toHex().toInt(0,16);
    m_value = package.body().mid(2,2).toHex().toInt(0,16);
}


quint16 NetControlPointCmd::address() const
{
    return m_address;
}

void NetControlPointCmd::setAddress(const quint16 &address)
{
    m_address = address;
}

quint16 NetControlPointCmd::value() const
{
    return m_value;
}

void NetControlPointCmd::setValue(const quint16 &value)
{
    m_value = value;
}




